package com.lf.api.example.blockingqueue;

import java.util.concurrent.BlockingQueue;

import com.lf.common.util.CommonUtil;

class Producer implements Runnable {
	private final BlockingQueue<String> queue;

	Producer(BlockingQueue<String> q) {
		queue = q;
	}

	public void run() {
		try {
			while (true) {
				//Thread.sleep(1000);
				queue.put(produce());
			}
		} catch (InterruptedException ex) {
			ex.printStackTrace();
		}
	}

	String produce() {
		String str = CommonUtil.randomNumbers();
		System.out.println("produce==" + str);
		return str;
	}
}
